<!doctype html>
<html>
<head>
	<title>ninejs类测试</title>
	<meta charset="utf-8" />
	<style type="text/css">
		* { margin: 0;padding: 0; }
		ul, ol, li { list-style: none; }

		.c1 { position: absolute;left: 200px;top: 200px;width: 300px;height: 300px;background: #FF0066; }
		.c2 { position: absolute;width: 100px;height: 100px;background: #FF0000; }
		.c3 { background: #FF6600; }
	</style>
	<script type="text/javascript" src="nine.js"></script>
	<script type="text/javascript" src="nine.eventDispatcher.js"></script>
	<script type="text/javascript" src="nine.arrayList.js"></script>
	<!-- script type="text/javascript" src="nine.imageCycle.js"></script>
	<script type="text/javascript" src="nine.popup.js"></script>
	<script type="text/javascript" src="nine.require.js"></script>
	<script type="text/javascript" src="nine.validator.js"></script -->
</head>
<body style="position:relative;">
	<!--<div id="box2" class="c2">22222</div>
	<div id="box1" class="c1">11111</div>
	<div id="box3">3333333</div>-->
	<div id="box4"></div>
	<div id="box5"></div>
	<script>
		// 测试ArrayList
		var oList = new ArrayList(["a", "b", "c"]);
		console.log("oList: ", oList);
		oList.removeAll();
		console.log("oList: ", oList);
		oList.addItem("d");
		console.log("oList: ", oList);

		/* ------------------------------------ /s ----------------------------------------- */
		// 测试print
		ninejs.extend(ninejs, function( exports ) {
			exports.printTest = function() {
				exports.print("", "ninejs", "printTest", "test", exports);
			};
		});
		ninejs.printTest();

		// 测试createClass
		ninejs.extend(ninejs, function( exports ) {
			exports.classTest = function() {
				var Animal = exports.createClass({
					name: "",
					ctor: function(name) {
						this.name = name;
						console.log("Animal's name is " + this.name);
					},
					say: function() {
						console.log("My name is " + this.name);
					}
				});
				console.log("Animal: ", Animal);
				var Cat = exports.createClass(Animal, {
					name: "",
					ctor: function(name) {
						this.name = name;
						console.log("Cat's name is " + this.name);
					},
					eat: function() {
						console.log(this.name + " eat mouse!");
					}
				});
				console.log("Cat: ", Cat);
				var kat = new Cat("Lucy");
				//kat.name = "kat";
				kat.say();
				console.log("kat: ", kat);
			};
		});
		ninejs.classTest();

		// 测试EventDispatcher
		ninejs.extend(ninejs, function( exports ) {
			//console.log("exports: ", exports);
			exports.eventTest = function() {
				// use函数
				exports.use(["nine.eventDispatcher"], function( exports ) {
					var EventTest = function() {};
					__extends(EventTest, exports.EventDispatcher);
					EventTest.prototype.name = "qiyan";
					EventTest.prototype.changeName = function(name) {
						this.name = name;
						this.dispatchEvent("CHANGE", { "name": name });
					};

					// test
					var oTest = new EventTest();
					console.log("your's name is: ", oTest.name);
					oTest.addEventListener("CHANGE", function(event) {
						console.log("event: ", event);
						console.log("you changed your's name: ", event.data.name);
					}, this);
					oTest.changeName("zjanhoo");
				});
			};
		});
		ninejs.eventTest();

		// 测试dom
		ninejs.extend(ninejs, function( exports ) {
			exports.domTest = function() {
				var elem = ninejs.getElemByTag("div");
				//console.log("elem: ", elem);
			};
		});

		/*
		// 测试animate
		ninejs.extend(ninejs, function( exports ) {
			exports.animateTest = function() {
				var box1 = exports.getElemById("box1");

				var an1 = new exports.AnimateEntry(30);
				an1.add('box_ani', box1, {left:220,top:300}, 1000, 'quadOut', 1000, function() {
					exports.addClass(box1, "c3");
					//exports.css(box1, {width:100,height:100});
				});
				//console.log("exports: ", exports);
				
				
				var box2 = exports.getElemById("box2");
				exports.css(box2, {opacity:1});
				var an2 = new exports.AnimateEntry();
				an2.fadeIn('box2_ani', box2, 1000, function() {
					an2.fadeOut('box3_ani', box2);
				});
				
			};
		});

		// 测试tween
		ninejs.extend(ninejs, function( exports ) {
			exports.tweenTest = function() {
				var elem = exports.getElemById("box2");
				exports.TweenEntry.to(elem, {"left":200,"top":100}, 15, function() {
					exports.TweenEntry.to(elem, {"width":800,"height":600}, 25);
				});
			};
		});

		// 测试drag
		ninejs.extend(ninejs, function( exports ) {
			exports.dragTest = function() {
				var box2 = exports.getElemById("box2");
				exports.DragEntry.setDrag(box2);
			};
		});
		
		// 测试md5
		ninejs.extend(ninejs, function( exports ) {
			exports.md5Test = function() {
				console.log(exports.Md5Entry.md5("zjanhoo"));
			};
		});

		// 测试validator
		ninejs.extend(ninejs, function( exports ) {
			//console.log("exports: ", exports);
			exports.validatorTest = function() {
				// 1. 配置数据
				exports.Validator.config = {
					firstname: 'isNonEmpty isNumber',
					age: 'isNumber',
					username: 'isAlphaNum'
				};
				var data = {
					firstname: "Super",
					lastname: "Man",
					age: "unknown",
					username: "o_O"
				};
				// 2. 开始验证
				exports.Validator.validate(data);
				// 3. 打印错误
				if ( exports.Validator.hasErrors() ) {
					//console.log(exports.Validator.messages.join("\n"));
				}
			};
		});


		// console.log("ninejs: ", ninejs);
		ninejs.extend(ninejs, function( exports ) {
			//console.log("exports: ", exports);
			exports.useTest = function() {
				// use函数
				exports.use(["nine.imagecycle","nine.popup","nine.md5","nine.validator","nine.tween"], function( exports ) {
					console.log("ninejs: ", exports);

					ninejs.domTest();
					
					ninejs.animateTest();
					
					ninejs.tweenTest();
					
					ninejs.dragTest();

					ninejs.md5Test();
					
					ninejs.validatorTest();
				});
			};
		});
		ninejs.useTest();

		
		var obj = { name: "zjanhoo" };
		ninejs.extend(obj, function( scope, exports ) {
			console.log("scope: ", scope);
			console.log("exports: ", exports);
		});
		
		// 测试 include
		ninejs.extend(function( exports ) {
			exports.include({
				"jQuery": "libs/jquery-latest.min.js",
				"angular": "libs/angular.min.js"
			}, function( $, ng ) {
					console.log("$: ", $);
					console.log("ng: ", ng);
					console.log("$: ", $("#box2"));
					console.log("ng: ", new ng.element("#box3"));
					console.log("ninejs: ", exports.element("#box1"));
				
			});
		});
		*/

		// 测试 loadRes
		ninejs.extend(function( exports ) {
			exports.loadRes([{
				name: "jQuery_js",
				type: "text/javascript",
				url: "TestFiles/jqm/jquery-1.11.1.min.js"
			}, {
				name: "jqueryMobile_css",
				type: "text/css",
				url: "TestFiles/jqm/jquery.mobile-1.4.5.min.css"
			}, {
				name: "g1_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/1.jpg"
			}, {
				name: "g2_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/2.jpg"
			}, {
				name: "g3_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/3.jpg"
			}, {
				name: "g4_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/4.jpg"
			}, {
				name: "g5_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/5.jpg"
			}, {
				name: "g6_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/6.jpg"
			}, {
				name: "g7_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/7.jpg"
			}, {
				name: "g8_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/8.jpg"
			}, {
				name: "g9_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/9.jpg"
			}, {
				name: "g10_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/10.jpg"
			}, {
				name: "g11_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/11.jpg"
			}, {
				name: "g12_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/12.jpg"
			}, {
				name: "g13_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/13.jpg"
			}, {
				name: "g14_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/14.jpg"
			}, {
				name: "g15_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/15.jpg"
			}, {
				name: "g16_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/16.jpg"
			}, {
				name: "g17_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/17.jpg"
			}, {
				name: "g18_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/18.jpg"
			}, {
				name: "g19_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/19.jpg"
			}, {
				name: "g20_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/20.jpg"
			}, {
				name: "g21_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/21.jpg"
			}, {
				name: "g22_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/22.jpg"
			}, {
				name: "g23_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/23.jpg"
			}, {
				name: "g24_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/24.jpg"
			}, {
				name: "g25_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/25.jpg"
			}, {
				name: "g26_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/26.jpg"
			}, {
				name: "g27_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/27.jpg"
			}, {
				name: "g28_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/28.jpg"
			}, {
				name: "g29_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/29.jpg"
			}, {
				name: "g30_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/30.jpg"
			}, {
				name: "g31_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/31.jpg"
			}, {
				name: "g32_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/32.jpg"
			}, {
				name: "g33_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/33.jpg"
			}, {
				name: "g34_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/34.jpg"
			}, {
				name: "g35_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/35.jpg"
			}, {
				name: "g36_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/36.jpg"
			}, {
				name: "g37_png",
				type: "image/jpg",
				url: "http://www.pic.com/37.png"
			}, {
				name: "g38_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/38.jpg"
			}, {
				name: "g39_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/39.jpg"
			}, {
				name: "g40_jpg",
				type: "image/jpg",
				url: "http://www.pic.com/40.jpg"
			}], {
				loading: function( lib, itemsLoaded, itemsTotal ) {
					var elem = lib.element("#box4");
					elem[0].innerHTML = "页面正在加载中。。。" + itemsLoaded + "/" + itemsTotal;
				},
				complete: function( lib ) {
					var elem = lib.element("#box4");
					elem[0].innerHTML = "加载完成！";
					
					var elem = lib.element("#box5");
					var str = '<ul>';
					for ( var i = 1; i <= 40; i++ ) {
						str += '<li><img src="http://www.pic.com/' + i + (i == 37 ? '.png' : '.jpg') + '" /></li>';
					}
					str += '</ul>';

					elem[0].innerHTML = str;
				}
			});
		});

		// 测试slider
		ninejs.use(["nine.slider"], function( exports ) {
			console.log("exports: ", exports);
			//exports.slider({
				
			//});
		});

		// 测试guid
		console.log(ninejs.uuid('5|5|5|5|5',16));
	</script>
	<!-- 测试广告 -->
	<!-- script src="nine.ad.js"></script -->
	<!-- script>
		/* 初始化广告 */
		
		function initAD( exports ) {
			// console.log("this: ", this.nodeName);	// SCRIPT
			if ( exports && exports.NineAD ) {
				exports.NineAD.initialize({
					pic: 'http://act.duoqu.com/static/images/ad.gif',
					url: 'http://pop.duoqu.com/gcld.html__1__gcld_004__147_573_1__19.html',
					title: '攻城略地'
				});
			}
		}

		loadjs("http://1250.sinaapp.com/ninejs/nine.js", appendAD, initAD);
		
	</script -->
</body>
</html>